package objects;

import java.util.Iterator;
import java.util.Vector;



public class User {
	private String _nameOfUser;
	private Vector<User> friendList;
	private Enum<Type> typeOfUser;
	public enum Type
    {
        DefaultUser,
        MANAGER,
        
    }
	
	// Constructors
	
	/**
	 * default constructor name of User will be Guest
	 */
	public User()
	{
		this._nameOfUser="Guest";
		friendList=new Vector<User>();
		typeOfUser = Type.DefaultUser;
	}
	
	
	public User(String nameOfUser)
	{
		friendList=new Vector<User>();
		this._nameOfUser=nameOfUser;
		typeOfUser = Type.DefaultUser;
	}
	/**
	 * make the User status as manager 
	 */
	public void setAsManager()
	{
		typeOfUser = Type.MANAGER;
	}
	
	public void setAsDefaultUser()
	{
		typeOfUser = Type.DefaultUser;
	}
	
	
	
	/**
	 * @return the typeOfUser
	 */
	public Enum<Type> getTypeOfUser() {
		return typeOfUser;
	}
	
	
	

	public void addfriend(User u)
	{
		this.friendList.add(u);
	}
	
	
	public void removefriend(User u)
	{
		this.friendList.remove(u);
	}
	
	/**
	 * remove friend by is name
	 * @param s the name of the friend to be remove
	 * @return 1 if friend removed ,-2 otherwise 
	 */
	public int removefriend(String s)
	{
		
		for (Iterator iterator = this.friendList.iterator(); iterator.hasNext();) {
			User u = (User) iterator.next();
			if (u.get_nameOfUser().equals(s))
			{
				this.friendList.remove(u);
				return 1;
			}
			
		}
		return -2;
		
	}
	
	
	
	//Getters
	
	/**
	 * @return the _nameOfUser
	 */
	public String get_nameOfUser() {
		return _nameOfUser;
	}

	/**
	 * @return the frindList
	 */
	public Vector<User> getFrindList() {
		return this.friendList;
	}


	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString()
	{
		return this._nameOfUser;
	}
	
	
}
